package com.pace.ribbon.asyn;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
public class Asyn {
    private Logger logger = LoggerFactory.getLogger(Asyn.class);

    @Async
    public void saveLog() {
        String name = Thread.currentThread().getName();
        logger.debug("开始保存日志文件,线程名为" + Thread.currentThread().getName());

        System.out.println("执行Asyn.saveLog开始，当前线程名称：" + name);

        // 执行一个非常耗时的循环
//        for (int i = 0; i < Integer.MAX_VALUE; i++) {
//            System.out.println(i*9999);
//        }
        System.out.println("执行Asyn.saveLog结束");

        logger.debug("保存日志文件结束");

    }

}
